//
//  HeaderView.m
//  A段项目
//
//  Created by dlios on 15/7/22.
//  Copyright (c) 2015年 dlios. All rights reserved.
//

#import "HeaderView.h"
#import "BaseHeader.h"

@implementation HeaderView

- (void)dealloc
{
    [_userName release];
    [_time release];
    [_forumName release];
    [_content release];
    [_location release];
    [_agreeCount release];
    [_commentCount release];
    [super dealloc];
}

- (instancetype)initWithFrame:(CGRect)frame
{
    if (self = [super initWithFrame:frame]) {
        [self create];
    }
    return self;
}

- (void)create
{
    self.userAvatar = [[UIImageView alloc] initWithFrame:CGRectMake(5, 5, 40, 40)];
    self.userAvatar.layer.cornerRadius = 20;
    self.userAvatar.layer.masksToBounds = YES;
    [self addSubview:_userAvatar];
    [_userAvatar release];
    
    
    self.userName = [[UILabel alloc] initWithFrame:CGRectMake(_userAvatar.frame.origin.x +_userAvatar.frame.size.width + 10, _userAvatar.frame.origin.y, ScreenWidth / 3 * 2, 20)];
    [self addSubview:_userName];
    [_userName release];
    
    
    self.time = [[UILabel alloc] initWithFrame:CGRectMake(_userName.frame.origin.x, _userName.frame.origin.y + _userName.frame.size.height + 10, 50, 20)];
    _time.textColor = [UIColor grayColor];
    _time.font = [UIFont systemFontOfSize:13];
    [self addSubview:_time];
    [_time release];
    
    
    self.forumName = [[UILabel alloc] initWithFrame:CGRectMake(_time.frame.origin.x + _time.frame.size.width + 10, _time.frame.origin.y, ScreenWidth / 3 * 2, 20)];
    _forumName.font = [UIFont systemFontOfSize:13];
    [self addSubview:_forumName];
    [_forumName release];
    
    
    self.content = [[UILabel alloc] initWithFrame:CGRectMake(_userName.frame.origin.x, _forumName.frame.origin.y + _forumName.frame.size.height + 10, ScreenWidth - _userName.frame.origin.x - 10, 100)];
    _content.font = [UIFont systemFontOfSize:14];
    _content.numberOfLines = 0;
    [self addSubview:_content];
    [_content release];
    
    self.location = [[UILabel alloc] initWithFrame:CGRectMake(_userName.frame.origin.x, _content.frame.origin.y + _content.frame.size.height + 10, 60, 20)];
    _location.textColor = [UIColor grayColor];
    _location.font = [UIFont systemFontOfSize:13];
    [self addSubview:_location];
    [_location release];
    
    UIImageView *image = [[UIImageView alloc] initWithFrame:CGRectMake(ScreenWidth - 120, _location.frame.origin.y, 20, 20)];
    image.image = [UIImage imageNamed:@"zan.png"];
    [self addSubview:image];
    [image release];
    
    self.agreeCount = [[UILabel alloc] initWithFrame:CGRectMake(ScreenWidth - 100, _location.frame.origin.y, 20, 20)];
    _agreeCount.textColor = [UIColor grayColor];
    _agreeCount.font = [UIFont systemFontOfSize:13];
    [self addSubview:_agreeCount];
    [_agreeCount release];
    
    
    UIImageView *imag = [[UIImageView alloc] initWithFrame:CGRectMake(_agreeCount.frame.origin.x + 40, _agreeCount.frame.origin.y, 20, 20)];
    imag.image = [UIImage imageNamed:@"14.png"];
    [self addSubview:imag];
    [imag release];
    
    
    self.commentCount = [[UILabel alloc] initWithFrame:CGRectMake(imag.frame.origin.x + 20, _agreeCount.frame.origin.y, 20, 20)];
    _commentCount.textColor = [UIColor grayColor];
    _commentCount.font = [UIFont systemFontOfSize:13];
    [self addSubview:_commentCount];
    [_commentCount release];
    
    UILabel *line = [[UILabel alloc] initWithFrame:CGRectMake(_userName.frame.origin.x, _commentCount.frame.origin.y + _commentCount.frame.size.height, ScreenWidth - 70, 1)];
    line.backgroundColor = [UIColor grayColor];
    [self addSubview:line];
    [line release];
    
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
